﻿using System.Collections.Generic;
using System.Text.Json.Serialization;
using WeChatBotSDK.JsonEx;

namespace WeChatBotSDK.Models
{
    /// <summary>
    /// 表示通用的 API 响应结构。
    /// </summary>
    public record GetWeChatListResponse
    {
        /// <summary>
        /// 响应代码。
        /// </summary>
        public int Code { get; set; } = -1;

        /// <summary>
        /// 返回的消息。
        /// </summary>
        public string Msg { get; set; } = "";

        /// <summary>
        /// 返回的结果列表。
        /// </summary>
        public List<WeChatInfo> Result { get; set; } = new List<WeChatInfo>();

        /// <summary>
        /// 时间戳。
        /// </summary>
        public string Timestamp { get; set; }= "";
    }

    /// <summary>
    /// 表示单个微信信息的结构。
    /// </summary>
    public record WeChatInfo
    {
        /// <summary>
        /// 开始运行时间戳。
        /// </summary>
        public string StartTimeStamp { get; set; }= "";

        /// <summary>
        /// 开始运行时间。
        /// </summary>
        public string StartTime { get; set; }= "";

        /// <summary>
        /// 已运行时间。
        /// </summary>
        public string RunTime { get; set; }= "";

        /// <summary>
        /// 接收到的消息数。
        /// </summary>
        public int Recv { get; set; }

        /// <summary>
        /// 发送的消息数。
        /// </summary>
        public int Send { get; set; }

        /// <summary>
        /// 微信号。
        /// </summary>
        public string WxNum { get; set; }= "";

        /// <summary>
        /// 昵称。
        /// </summary>
        public string Nick { get; set; }= "";

        /// <summary>
        /// 微信唯一标识。
        /// </summary>
        public string Wxid { get; set; }= "";

        /// <summary>
        /// 进程 ID。
        /// </summary>
        public string Pid { get; set; }= "";

        /// <summary>
        /// HTTP 监听端口。
        /// </summary>
        public string Port { get; set; }= "";
    }

    /// <summary>
    /// 列表信息
    /// </summary>
    public partial class 列表信息
    {
        /// <summary>
        /// 头像大图
        /// </summary>
        [JsonPropertyName("avatarMaxUrl")]
        public string AvatarMaxUrl { get; set; }

        /// <summary>
        /// 头像小图
        /// </summary>
        [JsonPropertyName("avatarMinUrl")]
        public string AvatarMinUrl { get; set; }

        /// <summary>
        /// 城市
        /// </summary>
        [JsonPropertyName("city")]
        public string City { get; set; }

        /// <summary>
        /// 国家
        /// </summary>
        [JsonPropertyName("country")]
        public string Country { get; set; }

        /// <summary>
        /// 英文简称
        /// </summary>
        [JsonPropertyName("enBrief")]
        public string EnBrief { get; set; }

        /// <summary>
        /// 英文全称
        /// </summary>
        [JsonPropertyName("enWhole")]
        public string EnWhole { get; set; }

        /// <summary>
        /// 群主wxid, 仅当查询对象是群聊时有效
        /// </summary>
        [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
        [JsonPropertyName("groupManger")]
        public string GroupManger { get; set; }

        /// <summary>
        /// 群成员数, 仅当查询对象是群聊时有效
        /// </summary>
        [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
        [JsonPropertyName("groupMemberNum")]
        public long? GroupMemberNum { get; set; }

        /// <summary>
        /// 朋友圈背景图
        /// </summary>
        [JsonPropertyName("momentsBackgroudImgUrl")]
        public string MomentsBackgroudImgUrl { get; set; }

        /// <summary>
        /// 昵称
        /// </summary>
        [JsonPropertyName("nick")]
        public string Nick { get; set; }

        /// <summary>
        /// 昵称简拼
        /// </summary>
        [JsonPropertyName("nickBrief")]
        public string NickBrief { get; set; }

        /// <summary>
        /// 昵称全拼
        /// </summary>
        [JsonPropertyName("nickWhole")]
        public string NickWhole { get; set; }

        /// <summary>
        /// 省份
        /// </summary>
        [JsonPropertyName("province")]
        public string Province { get; set; }

        /// <summary>
        /// 备注
        /// </summary>
        [JsonPropertyName("remark")]
        public string Remark { get; set; }

        /// <summary>
        /// 备注简拼
        /// </summary>
        [JsonPropertyName("remarkBrief")]
        public string RemarkBrief { get; set; }

        /// <summary>
        /// 备注全拼
        /// </summary>
        [JsonPropertyName("remarkWhole")]
        public string RemarkWhole { get; set; }

        /// <summary>
        /// 性别, 0=未知，1=男，2=女
        /// </summary>
        [JsonConverter(typeof(StringToEnumConverter<SexEnum>))]
        [JsonPropertyName("sex")]
        public SexEnum Sex { get; set; }

        /// <summary>
        /// 个性签名
        /// </summary>
        [JsonPropertyName("sign")]
        public string Sign { get; set; }

        /// <summary>
        /// V3数据
        /// </summary>
        [JsonPropertyName("v3")]
        public string V3 { get; set; }

        /// <summary>
        /// 微信ID
        /// </summary>
        [JsonPropertyName("wxid")]
        public string Wxid { get; set; }

        /// <summary>
        /// 微信号
        /// </summary>
        [JsonPropertyName("wxNum")]
        public string WxNum { get; set; }
    }
}
